"这个档案癿双引号 (") 是批注
set hlsearch
"高亮度反白
set backspace=2
"可随时用退格键删除
set autoindent
set smartindent
set ruler
"自劢缩排
"可显示最后一行癿状态
"set showmode
"set nu
"左下角那一行癿状态
"可以在每一行癿最前面显示行号啦!
"set bg=dark
syntax on
"显示丌同癿底色色调
"迚行语法检验,颜色显示。
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
"设置缩进"
set tabstop=4
set sw=4
set expandtab
"set encoding=utf-8 fileencodings=ucs-bom,utf-8,cp936
set encoding=utf-8
set fileencodings=ucs-bom,utf-8,cp936,gb18030
map <F8> :NERDTree<CR>

inoremap jj NERDTree
colorscheme desert
"colo evening
"pydiction 1.2 python auto complete
filetype plugin on
let g:pydiction_location = '~/.vim/tools/pydiction/complete-dict'
"defalut g:pydiction_menu_height == 15
"let g:pydiction_menu_height = 20 
"NERD Tree
let NERDChristmasTree=1
let NERDTreeAutoCenter=1
let NERDTreeBookmarksFile=$VIM.'\Data\NerdBookmarks.txt'
let NERDTreeMouseMode=2
let NERDTreeShowBookmarks=1
let NERDTreeShowFiles=1
let NERDTreeShowHidden=1
let NERDTreeShowLineNumbers=1
let NERDTreeWinPos='left'
let NERDTreeWinSize=31
nnoremap f :NERDTreeToggle
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o

"编译C源文件
func! CompileGcc()
    exec "w"
    let compilecmd="!gcc -Wall -pedantic -std=c99 "
    let compileflag="-o %<"
    exec compilecmd." % ".compileflag
endfunc

" 编译C++源文件
func! CompileCpp()
    exec "w"
    let compilecmd="!g++ -Wall -pedantic -std=c++98 "
    let compileflag="-o %<"
    exec compilecmd." % ".compileflag
endfunc
"编译Java源文件
func! CompileJava()
    exec "w"
    exec "!javac %"
endfunc

" 编译Haskell源文件
func! CompileHaskell()
    exec "w"
    let compilecmd="!ghc --make "
    let compileflag="-o %<"
    exec compilecmd." % ".compileflag
endfunc

" 运行Lua源文件
func! RunLua()
    exec "w"
    exec "!lua %"
endfunc

" 运行Perl源文件
func! RunPerl()
    exec "w"
    exec "!perl %"
endfunc
"运行Python源文件
func! RunPython()
    exec "w"
    exec "!python %"
endfunc

" 运行Ruby源文件
func! RunRuby()
    exec "w"
    exec "!ruby %"
endfunc

"根据文件类型自动选择相应的编译函数
func! CompileCode()
    exec "w"
    if &filetype == "c"
    exec "call CompileGcc()"
    elseif &filetype == "cpp"
    exec "call CompileCpp()"
    elseif &filetype == "java"
    exec "call CompileJava()"
    elseif &filetype == "haskell"
    exec "call CompileHaskell()"
    elseif &filetype == "lua"
    exec "call RunLua()"
    elseif &filetype == "perl"
    exec "call RunPerl()"
    elseif &filetype == "python"
    exec "call RunPython()"
    elseif &filetype == "ruby"
    exec "call RunRuby()"
    endif
endfunc

    "
"运行可执行文件
func! RunResult()
    exec "w"
    if &filetype == "c"
    exec "! %<"
    elseif &filetype  == "cpp"
    exec "! %<"
    elseif &filetype  == "java"
    exec "!java %<"
    elseif &filetype  == "haskell"
    exec "! %<"
    elseif &filetype  == "lua" 
    exec "!lua %<.lua"
    elseif &filetype  == "perl"
    exec "!perl %<.pl"
    elseif &filetype  == "python"
    exec "!python %<.py"
    elseif &filetype  == "ruby"
    exec "!ruby %<.rb"
    endif
endfunc
"Ctrl + C 一键保存、运行

map <F7> :call CompileCode()<CR>
imap <F7> <ESC>:call CompileCode()<CR>
vmap <F7> <ESC>:call CompileCode()<CR>

"Ctrl + R 一键保存、运行
map <F9> :call RunResult()<CR>
imap <F9> <ESC>:call RunResult()<CR>
vmap <F9> <ESC>:call RunResult()<CR>


